<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
   <title>登陆</title>
   <link rel="stylesheet" href="../css/bootstrap.min.css">
   <script type="text/javascript">
	function validate_form(thisform){
		with (thisform)
 		 {
			if(username.value=='')
			{
				document.getElementById('username_tip').innerHTML=
				"用户名不能为空";
				return false;
			}
			if(password.value=='')
			{
				document.getElementById('password_tip').innerHTML=
				"密码不能为空";
				return false;
			}
			if(username.value.length < 2 || username.value.length > 20){
				document.getElementById('username_tip').innerHTML=
				"请输入合法的用户名";
				return false;
			}
			if(password.value.length < 6 ||  password.value.length > 20){
				document.getElementById('password_tip').innerHTML=
				"密码不正确";
				return false;	
			}
  			return true;
  		}
	}
	function clear_tip(thisform){
		with(thisform){
			document.getElementById('username_tip').innerHTML=
				"";
			document.getElementById('password_tip').innerHTML=
				"";
		}
	}
</script>
</head>
<body>
<div style="margin-left:100px;margin-right:100px;">
	<p align="right" style="margin-top:10px">
		<a href='../home/home.php'>返回首页</a>
	</p>
</div><hr/>
<div style="margin-top:50px;margin-left:250px">
<form class="form-horizontal" role="form"action="../handle/login.php" method="post" onSubmit="return validate_form(this)">
   <div class="form-group">
      <label for="username" class="col-sm-2 control-label">用户名:</label>
      <div class="col-sm-4">
         <input type="text" class="form-control" id="username" 
         	name="username" placeholder="请输入用户名(2-20位)" 
            onClick= "clear_tip(this)">
      </div>
      <label name="username_tip" id="username_tip" style="color:#F00">
      </label>
   </div>
   <div class="form-group">
      <label for="password" class="col-sm-2 control-label">密  码:</label>
      <div class="col-sm-4">
         <input type="password" class="form-control" id="password" 
         name="password" placeholder="请输入密码(6-20位)" 
         onClick="clear_tip(this)">
      </div>
      <label name="password_tip" id="password_tip" style="color:#F00">
      	<?php 
			if(isset($_GET['tip'])){
				if($_GET['tip'] == 1){
					echo "用户名或密码错误,请重新输入";
				}
			}
		?>  
      </label>
   </div>
   <div class="form-group">
      <div class="col-sm-offset-2 col-sm-1">
         <button type="submit" class="btn btn-default">登录</button>
      </div>
     
      <div class="col-sm-offset-0 col-sm-1">
          <button type="button" class="btn btn-default" 
          onClick="location='register-face.php'">注册</button>
      </div>
   </div>
</form>
</div>
<?php require('../public/footer.php');?>
</body>
</html>